<?php
include('handler_bd.php');
session_start();

$user = $_POST['user'];
$pass = $_POST['pass'];
$hashpass = md5($pass);


$result = $conn->query("SELECT * FROM Users WHERE nombre = '$user' AND password = '$hashpass'");
if ($result->fetch()){
	 $_SESSION['loggedin'] = true;
	 $_SESSION['username'] = $user;
	 header("refresh:1;url=admin.php");
	 
  }
  else{
  	header("refresh:1;url=admin.php?fail=true");
  }
  

if(isset($_SESSION['loggedin'])){    
    exit;
};
?>